package event;

import model.code.Function;

/**
 * This is for events in which a {@link Function} has one of its parameters moved in order.
 *
 * Authors: Neil Dickson
 */
public class ParameterMovedEvent extends SymbolChangeEvent {
	private	int		oldIndex;
	private	int		newIndex;

	public ParameterMovedEvent(Function function,int oldIndex,int newIndex) {
		super(function);
		this.oldIndex = oldIndex;
		this.newIndex = newIndex;
	}
	public Undoable undo() {
		((Function)symbol).moveParameter(newIndex,oldIndex);
		return new ParameterMovedEvent((Function)symbol,newIndex,oldIndex);
	}

	public String getDescription() {
		return "Moved "+symbol.getName()+" parameter "+oldIndex+" to position "+newIndex;
	}
}
